#include "CompressData.h"


CompressData::CompressData(EntryCMCollection *vector)
{
	CompressData::vector=vector;
}


CompressData::~CompressData(void)
{
}

void CompressData::findRedundancy(){
	int countRedundance=0;
	EntryCM *pointerPre=&vector->getElement(0);
	int i=1;

	while(i<vector->length())
	{
		EntryCM *pointerCurr=&vector->getElement(i);
		if(compare(pointerPre,pointerCurr))
		{
			countRedundance++;
			if(countRedundance>=2){
				vector->remove(i);
				continue;
			}
			i++;
		}
		else
		{
			countRedundance=0;
			i++;
		}
		pointerPre=pointerCurr;
	}
}
bool CompressData::compare(EntryCM *a, EntryCM *b){
	if(a->getES()==b->getES()&& a->getFRT()==b->getFRT()&&a->getKF()==b->getKF()&&a->getLL()==b->getLL()&&a->getPA()==b->getPA()&&a->getRGF()==b->getRGF()&&a->getSM()==b->getSM()&&a->getSZ()==b->getSZ())
		return true;
	else
		return false;
}